<!DOCTYPE HTML>
<html>
	<head>
		<script>
			$(function () {
                $('#dp1').datepicker();
				$('#dp2').datepicker();
				$('#dp3').datepicker();
            });
			</script>
			<script type="text/javascript" src="angular.min.js"></script>
			<script type="text/javascript" src="tran_search_ajs.js"></script>
			
	</head>
 
<body>
<div align="center">
<?php
	include('conn.php');	
	include('top.php');   
	$pnr =$_REQUEST['no'];
	
	$sql3="select proposalno,policyno from transactionmast where status = '0'";
	$res3=mysql_query($sql3);		
	while($row = mysql_fetch_assoc($res3)){
		$pnrs1[] = $row["proposalno"]; 			
		$pnrs2[] = $row["policyno"]; 			
	}	
	
	$size1 = count($pnrs1); 
	$size2 = count($pnrs2); 
	$chk="n";
	for($i=0;$i<$size1;$i++)	
		if(strcasecmp($pnr, $pnrs1[$i]) == 0)
			$chk="y";	
	if (strcasecmp($pnr,'')==0)
		$chk="n";		
	if (strcasecmp($chk,"y")!==0)
	{	
		for($i=0;$i<$size2;$i++)	
			if(strcasecmp($pnr, $pnrs2[$i]) == 0)
				$chk="y";
		if (strcasecmp($chk,"y")!==0)
		{
			$msg="This proposal/policy number does not exist! Enter a valid PNR";		
			printf("<script type='text/javascript'>location.href='tran_search_ajs.php?&msg=".$msg." '</script>");
		}
		else
			getData($pnr);
	}	
	else
	{							
		getData($pnr);
	}	
	
	function getData($pnr)
	{
		$sql1="select * from transactionmast where policyno='$pnr' or proposalno='$pnr';";
		//echo $sql1;
		$res1=mysql_query($sql1);		
		$row = mysql_fetch_assoc($res1);
		
		$GLOBALS['id'] = $row["trnid"]; 						
		$GLOBALS['dt'] = $row["inwarddate"]; 						
		$GLOBALS['prno'] = $row["proposalno"]; 						
		$GLOBALS['pono'] = $row["policyno"]; 						
		$GLOBALS['awb'] = $row["awbno"]; 						
		$GLOBALS['fbc'] = $row["filebarcode"]; 						
		$GLOBALS['cbc'] = $row["cartonbarcode"]; 						
		$cid = $row["courierid"]; 						
		$did = $row["districtid"]; 						
		$GLOBALS['rem'] = $row["remarks"]; 	
		//echo var_dump($row);
		
		$sql1="select d.districtname,c.couriername from districtmast d , couriermast c
			where districtid='$did' and courierid='$cid';";		
		$res1=mysql_query($sql1);		
		$row = mysql_fetch_assoc($res1);
		$GLOBALS['courier'] = $row["couriername"];
		$GLOBALS['dis'] = $row["districtname"];
		//echo $sql1.var_dump($row);
	}
?>

	<div ng-app="myApp" ng-controller="ListCustCtrl">
<br/><h2>Update Record for <? echo $pnr ?></h2>
<br/><br/> 
<input type="hidden" ng-init="tsp.trnid='<?php echo $id; ?>'" ng-model="tsp.trnid"/>
<form name="AddNewForm"  method="post">
 <table>
    <tr>
		<td>*Inward Date : </td>
		<td>
			<input type="text" id="dp1"  class="input-medium" ng-model="tsp.inwarddate" ng-init="tsp.inwarddate='<?php echo $dt; ?>'" required />
			</td>
		<td>&nbsp;&nbsp;Proposal Number :  </td>
		<td><input type="text" class="input-medium" ng-model="tsp.proposalno" ng-init="tsp.proposalno='<?php echo $prno; ?>'"/></td>
		<td>&nbsp;&nbsp;*Policy Number : </td>
		<td><input type="text" class="input-medium" ng-model="tsp.policyno" ng-init="tsp.policyno='<?php echo $pono; ?>'" required /></td>
	</tr>
    
    <tr>
		<td>File barcode : </td>
		<td><input type="text" class="input-medium" ng-model="tsp.filebarcode" ng-init="tsp.filebarcode='<?php echo $fbc; ?>'" /></td>
		<td>&nbsp;&nbsp;Carton barcode : </td>
		<td><input type="text" class="input-medium" ng-model="tsp.cartonbarcode" ng-init="tsp.cartonbarcode='<?php echo $cbc; ?>'" /></td>
		<td>&nbsp;&nbsp;AWB Number : </td>
		<td><input type="text" class="input-medium" ng-model="tsp.awbno" ng-init="tsp.awbno='<?php echo $awb; ?>'" /></td>
    </tr>
    
    <tr>
      <td>*Mode: </td>
	  <td><input type="text" class="input-medium" ng-model="tsp.courierid" ng-init="tsp.courierid='<?php echo $courier; ?>'" required auto-complete ui-items="modearr" /></td>
      <td>&nbsp;&nbsp;*City: </td>
	  <td><input type="text" class="input-medium" ng-model="tsp.districtid" ng-init="tsp.districtid='<?php echo $dis; ?>'" required auto-complete ui-items="cityarr" /></td>
      <td>&nbsp;&nbsp;Comment: </td>
	  <td><input type="text" class="input-medium" ng-model="tsp.remarks" ng-init="tsp.remarks='<?php echo $rem; ?>'" /></td>
    </tr>
       
  </table>
</br>  
        <a class="btn btn-success" ng-click="updtcustdata(tsp,'2')">Update</a>		
        <a href="tran_search_ajs.php" class="btn">Cancel</a>	<br/><br/>
    </form>
</div></div>
</body>
</html>